
var loc_stor = {};//本地缓存
function Ajax(ec_type,btime3,line_type,dname,lid){
    ec_type = ec_type || 'line';
    btime3 = btime3 || '2015年07月';
    line_type = line_type || 'tnum';
    dname = dname || '';
    lid = lid || '';
    var year = btime3.substr(0,4);
    var month = btime3.substr(5,2);
    var key = year+month+line_type+dname+lid;
    if(loc_stor[key]){
        init(loc_stor[key])
    }else{
        require.config({
            paths: {
                echarts: 'http://www.12301.cc/js/echarts-2.2.1/src',
                theme  : 'http://www.12301.cc/js/echarts-2.2.1/src/theme',
                zrender: 'http:///www.12301.cc/js/echarts-2.2.1/zrender'
            }
        });
        require(
            [
                'echarts',
                'theme/macarons',
                'echarts/chart/line',
                'echarts/chart/pie',
                'echarts/chart/map'
            ],
            function (ect,theme) {
                for(var i=0;i<3;i++){
                    var dom = $('.mainbox .header_map')[i];
                    var myChart = ect.init(dom,theme);
                    var key = 'myChart'+i;
                    loc_stor[key] = myChart;
                    loc_stor[key].showLoading({
                        text: "正在拼命加载数据(｡・`ω´･)",
                        effect:'dynamicLine'
                    });
                }
                PFT_GLOBAL.G.Ajax({
                        url : "t.php",
                        data : {action:'line',btime3:btime3,line_type:line_type,dname:dname,lid:lid},
                        dataType : "json",
                        type :'POST',
                        loading:function(){},
                        timeout : function(){console && console.log("获取数据超时")},
                        serverError : function(){console &&
                        console.log("接口出错:map_3/t.php?all")}
                    },function(res){
                        var key =  year+month+line_type+dname+lid;
                        loc_stor[key] = res;
                        for(var i=0;i<3;i++){
                            var option = res[i];
                            var key = 'myChart'+i;
                            loc_stor[key].hideLoading();
                            console.log(option)
                            loc_stor[key].setOption(option);
                        }
                    }
                )
            }
        )
    }
}




